home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…eptember: Technology Seed / September 98 ADC Seed CD.toast / Language Analysis Manager / DarumaDR1Package / Examples / LanguageAnalysisTestApp / Sources / TestAppUtilities.c < prev   
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.7 KB  |  113 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        TestAppUtilities.c
  3.  
  4.      Contains:    Sample code for Language Analysis Manager.
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Daruma Developer Release 1
  8.  
  9.      Copyright:    1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Contact:    daruma@apple.com
  12.  
  13. */
  14.  
  15.  
  16. #include "TestApp.h"
  17. #include "FunctionProto.h"
  18.  
  19. #include <Windows.h>
  20. #include <TextUtils.h>
  21. #include <string.h>
  22. #include <Memory.h>
  23.  
  24.  
  25. // ========================================================================================
  26. // ShowErrorAlert
  27. // ========================================================================================
  28. void ShowErrorAlert ( OSStatus error )
  29. {
  30.     Str31        errNumStr;
  31.     
  32.     if ( error == noErr) return;
  33.     
  34.     NumToString( error, errNumStr);
  35.     ParamText( errNumStr, (unsigned char *)"", (unsigned char *)"", (unsigned char *)"");
  36.     
  37.     Alert( kErrorAlertResID, NULL);
  38. }
  39.  
  40.  
  41. // ========================================================================================
  42. // ShowCautionAlert
  43. // ========================================================================================
  44. void ShowCautionAlert ( void *msg1, void *msg2 )
  45. {
  46.     ParamText( (StringPtr)msg1, (StringPtr)msg2, (StringPtr)"", (StringPtr)"");
  47.     
  48.     Alert( kCautionAlertResID, NULL);
  49. }
  50.  
  51.  
  52. // ========================================================================================
  53. // IsInputDialog
  54. // ========================================================================================
  55. Boolean IsInputDialog ( WindowRef window )
  56. {
  57.     Str255        title;
  58.     
  59.     if ( window != NULL)
  60.     {
  61.         GetWTitle( window, title);
  62.         return EqualString( title, "\pInput", true, true);
  63.     }
  64.     
  65.     return false;
  66. }
  67.  
  68.  
  69. // ========================================================================================
  70. // GetDialogItemHandle
  71. // ========================================================================================
  72. Handle GetDialogItemHandle ( DialogRef dialog, short itemNo )
  73. {
  74.     short    itemType;
  75.     Handle    itemHandle;
  76.     Rect    box;
  77.     
  78.     GetDialogItem( dialog, itemNo, &itemType, &itemHandle, &box);
  79.     return itemHandle;
  80. }
  81.  
  82.  
  83. // ========================================================================================
  84. // PascalStrToCStr
  85. // ========================================================================================
  86. char *PascalStrToCStr ( StringPtr pStr )
  87. {
  88.     long    len = (long)pStr[0];
  89.     
  90.     BlockMoveData( &pStr[1], &pStr[0], len);
  91.     pStr[len] = '\0';
  92.     
  93.     return (char *)&pStr[0];
  94. }
  95.  
  96.  
  97. // ========================================================================================
  98. // CStrToPascalStr
  99. // ========================================================================================
  100. StringPtr CStrToPascalStr ( char *cStr )
  101. {
  102.     long    len = strlen( cStr);
  103.     
  104.     BlockMoveData( &cStr[0], &cStr[1], len);
  105.     cStr[0] = len;
  106.     
  107.     return (StringPtr)&cStr[0];
  108. }
  109.  
  110.  
  111.  
  112.  
  113.